{% extends 'backstage/admin/manage_task/base.html' %}
{% from 'bootstrap/pagination.html' import render_pagination %}

{% block task_content %}
    {% if is_start() %}
        <div class="table-responsive">
            <table class="table table-striped table-hover table-sm">
                <thead>
                <tr class="text-center">
                    <th>#</th>
                    <th>{{ _('Team number') }}</th>
                    <th>{{ _('Problem') }}</th>
                    <th>{{ _('Score') }}</th>
                    <th>{{ _('Remark') }}</th>
                    <th>{{ _('Actions') }}</th>
                </tr>
                </thead>
                {% for task in pagination.items %}
                    <tr>
                        <td class="text-center">
                            {{ pagination.total - (config['SOLUTION_PER_PAGE']*(page-1) + loop.index) + 1 }}
                        </td>
                        <td class="text-center">
                            <span class="badge badge-pill badge-info">
                                {{ task.team_number }}
                            </span>
                        </td>
                        <td class="text-center">
                <span class="badge badge-pill badge-primary">
                    {{ task.problem }}
                </span>
                        </td>
                        <td class="text-center">{{ task.score }}</td>
                        <td class="text-center">{{ task.remark }}</td>
                        <td class="text-center">
                            <button class="btn btn-danger btn-sm" data-toggle="modal" data-target="#confirm-delete"
                                    data-href="{{ url_for('admin.method_delete_task', task_id=task.id) }}">
                                <span class="oi oi-trash" aria-hidden="true"></span> {{ _('Delete') }}
                            </button>
                        </td>
                    </tr>
                {% endfor %}
            </table>
        </div>
        <div class="page-footer">
            {{ render_pagination(pagination) }}
        </div>
    {% else %}
        {% include "backstage/tips/no_start.html" %}
    {% endif %}

    <div class="modal fade" id="confirm-delete" tabindex="-1" role="dialog" aria-labelledby="confirmModalLabel"
         aria-hidden="true">
        <div class="modal-dialog modal-sm">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="confirmModalLabel">
                        {{ _('Delete Confirm') }}
                    </h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span class="oi oi-delete"></span>
                    </button>
                </div>
                <div class="modal-body">
                    <p>{{ _('Are you sure you want to delete this item?') }}</p>
                </div>
                <div class="modal-footer">
                    <form class="delete-form" method="post">
                        <input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
                        <button type="button" class="btn btn-default" data-dismiss="modal">
                            <span class="oi oi-action-undo"></span> {{ _('Cancel') }}
                        </button>
                        <button class="btn btn-danger btn-confirm" type="submit">
                            <span class="oi oi-trash"></span> {{ _('Delete') }}
                        </button>
                    </form>
                </div>
            </div>
        </div>
    </div>
{% endblock %}
